import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/page/home/model/certification_entity.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';

class CollectionCertificateListCell extends StatefulWidget {
  const CollectionCertificateListCell(
      {Key key, this.data, this.onCancelCallback, this.onClickCallback})
      : super(key: key);

  final CertificationEntity data;
  final GestureTapCallback onCancelCallback;
  final GestureTapCallback onClickCallback;

  @override
  _CollectionCertificateListCellState createState() =>
      _CollectionCertificateListCellState();
}

class _CollectionCertificateListCellState
    extends State<CollectionCertificateListCell> {
  @override
  Widget build(BuildContext context) {
    return Slidable(
        actionPane: SlidableDrawerActionPane(),
        actionExtentRatio: 0.2,
        secondaryActions: <Widget>[
          IconSlideAction(
            caption: '取消收藏',
            color: ThemeColors.colorType30,
            icon: Icons.cancel,
            onTap: widget.onCancelCallback,
          ),
        ],
        child: _initCell());
  }

  Widget _initCell() {
    return GestureDetector(
        onTap: widget.onClickCallback,
        child: Container(
          color: ThemeColors.colorWhite,
          padding: EdgeInsets.symmetric(
              horizontal: ScreenAdapter.width(30),
              vertical: ScreenAdapter.height(20)),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Row(
                children: <Widget>[
                  Container(
                    width: ScreenAdapter.width(50),
                    height: ScreenAdapter.width(50),
                    margin: EdgeInsets.only(right: ScreenAdapter.width(18)),
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                        color: ThemeColors.colorType6,
                        borderRadius:
                            BorderRadius.circular(ScreenAdapter.width(8))),
                    child: Text("资",
                        style: TextStyle(
                            color: ThemeColors.colorWhite,
                            fontSize: ScreenAdapter.sp(30),
                            fontWeight: FontWeight.bold)),
                  ),
                  Expanded(
                    child: Text(
                      widget.data.Name,
                      style: TextStyle(
                          color: ThemeColors.colorType1,
                          fontWeight: FontWeight.w500,
                          fontSize: ScreenAdapter.sp(30)),
                    ),
                  ),
                ],
              ),
              // SizedBox(height: ScreenAdapter.height(15)),
              Padding(
                  padding: EdgeInsets.only(top: ScreenAdapter.width(25)),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Expanded(
                          child: Text(
                        "注册企业：" + widget.data.CompanyName ?? "-",
                        maxLines: 1,
                        softWrap: true,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            color: ThemeColors.colorType7,
                            fontSize: ScreenAdapter.sp(26)),
                      )),
                      Text(
                        widget.data.StartDate,
                        style: TextStyle(
                            color: ThemeColors.colorType7,
                            fontSize: ScreenAdapter.sp(26)),
                      )
                    ],
                  ))
            ],
          ),
        ));
  }
}
